package net.wofly.common.util;

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;

public class ExcelUtil {
    /**
     * 转换状态为“有”或“无”
     * @param row
     * @param indexCell
     * @param cellValue
     */
    public static void addCellValueForIntegerStatus(XSSFRow row, int indexCell, Integer cellValue){
        if (cellValue != null && cellValue == 1) {
            addCellValueForString(row, indexCell, "有");
        } else {
            addCellValueForString(row, indexCell, "无");
        }
    }

    public static void addCellValueForString(XSSFRow row, int indexCell, String cellValue){
        XSSFCell cell = row.getCell(indexCell);
        if (null == cell) {
            cell = row.createCell(indexCell);
        }
        cell.setCellValue(cellValue);
    }
}
